package com.cgt.day5.Exercise;

public class Student extends Person implements  Subject{
    private String ClassName;//子类私有属性，只可以有自己类内部访问
    public static String country = "china";
//  静态属性，为常量
    public Student(){
        super();//父类构造方法
    }

    public Student(int id, int age, String name, String gender, String className) {
        super(id, age, name, gender);
        ClassName = className;
    }
//  重写
    @Override
    public void show() {
        System.out.println("Student.show");
//        super.show();
        System.out.println(country);
        print();
//        非静态可以调用静态，静态无法调用非静态
        System.out.println(name);
        System.out.println();
    }
//  静态方法
    public static void print(){
        System.out.println("Student.print");
        System.out.println(country);
//        show();
//        Non-static method 'show()' cannot be referenced from a static context
//        System.out.println(name);
//        Non-static field 'name' cannot be referenced from a static context
//        静态方法只能调用静态属性
        System.out.println();
    }
//  子类独有的方法
    public void stu(){
        System.out.println("Student.stu");
    }
//  多态
    @Override
    public String getRoomName() {
        return ClassName;
    }
//  重载
    @Override
    public String toString() {
        return "Student{" +
                "ClassName='" + ClassName + '\'' +
                ", id=" + id +
                ", age=" + age +
                ", name='" + name + '\'' +
                ", gender='" + gender + '\'' +
                '}';
    }
//   父类的抽象方法
    @Override
    public void chooseSubject() {
        System.out.println("Student.chooseSubject");
    }

    public void study(){
        System.out.println("Student.study");
        System.out.println(id);
        System.out.println(age);
        System.out.println(name);
        System.out.println(gender);
        System.out.println(ClassName);
    }
}
